import { useEffect, useState } from 'react';
import axios from 'axios';

function App() {
  const [message, setMessage] = useState('');

  // 调用后端API
  useEffect(() => {
    // 获取欢迎消息
    axios.get('/api/hello')
      .then(res => setMessage(res.data.data))
      .catch(err => console.error('获取消息失败:', err));
  }, []);

  return (
    <div style={{ padding: '2rem' }}>
      <p>{message}</p>
    </div>
  );
}

export default App;
